package cn.wx.jove.core.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import cn.wx.common.persistence.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import cn.wx.jove.core.service.UserService;
import cn.wx.jove.core.entity.User;
import cn.wx.common.persistence.web.ResponseData;
import cn.wx.jove.core.entity.qo.UserQ;
/**
 *   @description : User 控制器
 *   ---------------------------------
 *   @author  
 *   @since 2018-11-30
 */
@RestController
@RequestMapping("/user")
public class UserController extends BaseController {

    @Autowired
    private UserService userService;

    /**
     * @description : 通过条件获取User
     * ---------------------------------
     * @author :  
     * @since : Create in 2018-11-30
     */
    @RequestMapping(value = "/query/unique", method = RequestMethod.POST)
    public ResponseData queryUnique(UserQ userQ) throws Exception {
        return success(userService.queryUnique(userQ,User.class));
    }

    /**
     * @description : 通过条件获取User分页
     * ---------------------------------
     * @author :  
     * @since : Create in 2018-11-30
     */
    @RequestMapping(value = "/query/page", method = RequestMethod.POST)
    public ResponseData queryPage(UserQ userQ) throws Exception {
        return success(userService.queryPage(userQ));
    }

	/**
     * @description : 通过条件获取User
     * ---------------------------------
     * @author : 
     * @since : Create in 2018-11-30
     */
    @RequestMapping(value = "/query/list", method = RequestMethod.POST)
    public ResponseData queryList(UserQ userQ) throws Exception {
        return success(userService.queryList(userQ));
    }
    
    /**
     * @description : 通过id删除User
     * ---------------------------------
     * @author :  
     * @since : Create in 2018-11-30
     */
    @RequestMapping(value = "/remove", method = RequestMethod.POST)
    public ResponseData remove(User user) throws Exception {
        return success(userService.remove(user));
    }

    /**
     * @description : 通过id更新User
     * ---------------------------------
     * @author :  
     * @since : Create in 2018-11-30
     */
    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    public ResponseData modify(User user) throws Exception {
        return success(userService.modify(user));
    }
    
    /**
     * @description : 新增User
     * ---------------------------------
     * @author :  
     * @since : Create in 2018-11-30
     */
     @RequestMapping(value = "/create", method = RequestMethod.POST)
     public ResponseData create(User user) throws Exception {
        return success(userService.create(user));
     }
}